\hypertarget{main_8c}{
\section{main.c File Reference}
\label{main_8c}\index{main.c@{main.c}}
}
{\ttfamily \#include $<$avr/interrupt.h$>$}\par
{\ttfamily \#include $<$avr/io.h$>$}\par
{\ttfamily \#include $<$stdint.h$>$}\par
{\ttfamily \#include \char`\"{}FreeRTOS.h\char`\"{}}\par
{\ttfamily \#include \char`\"{}task.h\char`\"{}}\par
{\ttfamily \#include \char`\"{}nxbot.h\char`\"{}}\par
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{main_8c_a840291bc02cba5474a4cb46a9b9566fe}{main} (void)
\begin{DoxyCompactList}\small\item\em The main function. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
xTaskHandle \hyperlink{main_8c_a530db8c8f5d4566f119839f2521d3f56}{commHandle}
\begin{DoxyCompactList}\small\item\em The handle for the communication task. \item\end{DoxyCompactList}\item 
xTaskHandle \hyperlink{main_8c_a6e4a3ffc616e13ac5f975a87d8b969ee}{soundHandle}
\begin{DoxyCompactList}\small\item\em The handle for the sound task. \item\end{DoxyCompactList}\item 
xTaskHandle \hyperlink{main_8c_a76d3eb261196f8d460dbe05cdc0eae6f}{sensorHandle}
\begin{DoxyCompactList}\small\item\em The handle for the sensor task. \item\end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function Documentation}
\hypertarget{main_8c_a840291bc02cba5474a4cb46a9b9566fe}{
\index{main.c@{main.c}!main@{main}}
\index{main@{main}!main.c@{main.c}}
\subsubsection[{main}]{\setlength{\rightskip}{0pt plus 5cm}int main (void)}}
\label{main_8c_a840291bc02cba5474a4cb46a9b9566fe}


The main function. Initializes all the hardware of the robot and creates the respective tasks to be used; one task is used for motor control, other for sensor update another one for the sound system (which is always sleeping, and only wakes up when it is needed), and one for the communication role between this system and the embedded one. Finally all the control is given to the scheduler, as the RTOS is implemented as a preemptive one (The scheduler is in charge of assigning CPU resources to each task. A Priority-\/ and Round-\/Robin strategy is used.

The tasks use the global\_\-t structure for sharing information and data. 

\subsection{Variable Documentation}
\hypertarget{main_8c_a530db8c8f5d4566f119839f2521d3f56}{
\index{main.c@{main.c}!commHandle@{commHandle}}
\index{commHandle@{commHandle}!main.c@{main.c}}
\subsubsection[{commHandle}]{\setlength{\rightskip}{0pt plus 5cm}xTaskHandle {\bf commHandle}}}
\label{main_8c_a530db8c8f5d4566f119839f2521d3f56}


The handle for the communication task. This task handles all the communication through the serial port (UART1). It is declared as a global variable, in order to use it in other modules of the firmware. \hypertarget{main_8c_a76d3eb261196f8d460dbe05cdc0eae6f}{
\index{main.c@{main.c}!sensorHandle@{sensorHandle}}
\index{sensorHandle@{sensorHandle}!main.c@{main.c}}
\subsubsection[{sensorHandle}]{\setlength{\rightskip}{0pt plus 5cm}xTaskHandle {\bf sensorHandle}}}
\label{main_8c_a76d3eb261196f8d460dbe05cdc0eae6f}


The handle for the sensor task. This task is in charge of updating all the data coming from the sensors and organize it in their respective structures declared in \hyperlink{structures_8h}{structures.h}. It is declared as a global variable, in order to use it in other modules of the firmware. \hypertarget{main_8c_a6e4a3ffc616e13ac5f975a87d8b969ee}{
\index{main.c@{main.c}!soundHandle@{soundHandle}}
\index{soundHandle@{soundHandle}!main.c@{main.c}}
\subsubsection[{soundHandle}]{\setlength{\rightskip}{0pt plus 5cm}xTaskHandle {\bf soundHandle}}}
\label{main_8c_a6e4a3ffc616e13ac5f975a87d8b969ee}


The handle for the sound task. This task is always suspended and only activated by the communication task. It handles the timing for the musical notes. It is declared as a global variable, in order to use it in other modules of the firmware. 